const Vue = require("../common/vue");
let order_service = require("../../service/order-service");
let _util = require('util/util.js');
const _account_service = require("../../service/account-service");
require('../common/header/index')
require('../common/sidebar/index')
let receiving_detail = new Vue({
    el: "#receiving-detail",
    data() {
        return {
            receivingVO: {
                receivingid: 1,
                addrcoutry: "",
                addrprovince: "",
                addrcouty: "",
                addrdetails: "",
                contactphone: "",
                receivename: ""
            }
        }
    },
    methods: {
        getReceiving: function(_this) {
            this.receivingVO.receivingid = _util.getQueryVariable("receivingID") || -1;
            if(this.receivingVO.receivingid !== -1){
                order_service.getReceiving(this.receivingVO.receivingid, function(res) {
                    _this.receivingVO = res; 
                }, function(err) {
                    console.log(err);
                })
            }
        },
        send: function() {
            order_service.postReceiving(this.receivingVO, function(res) {
                window.location.href = "/view/receiving_all.html";
            }, function(err) {
                console.log(err);
            });
        }
    },
    created: function(){
        this.getReceiving(this);
    }
});

